<style type='text/css'>
	.addAccount_form{
		border: 1px solid #D9D9D9;
		padding: 15px;
		margin-left: 15px;
		margin-right: 15px;
		margin-top: 5px;
		margin-bottom: 5px;
	}
	
	#addAccount_form table tr td{
		vertical-align: middle;
		padding-left: 10px;
		padding: 8px;
	}
	.input{  
	        border: 1px 
	        solid #46A3FF;
	        height:18px;
	        width:;  
	        maxlength: 
	        
	        }
	        .input1{  
	        border: 1px 
	        solid #46A3FF;
	        height:18px;
	        width:380px;  
	        maxlength: 
	        
	        }
	
</style>

<script type="text/javascript">

function closeJbox() {
	$.jBox.close(true);
}

function submit_account(){
	if(!checkRequiredInputs()){
		return false;
	}
	
	$.ajax({
    	type:'POST',
        url:'/lottery/accounts/submit_add', 
        data: $("#addAccount_form").serialize(),
        success:function(data,status){
        	$.jBox.tip('新增成功', 'success');
	       	$('#accounts_grid').datagrid('reload');
			$.jBox.close(true);
        },
        error:function (req, status, error){
        	$.jBox.tip(' ' + req.responseText, 'error');
        }
    }); 
	return true;
	}
	

function checkRequiredInputs(){
	var re = /^[-]?[0-9]+[\.]?[0-9]*$/;
	var ide = /\d{17}[\d|X]|\d{15}/;
	ratiovalue = $("#ratio").val()
	balance = $("#balance").val()
	identi = $("#identify").val()
	if(!re.test(ratiovalue) || parseFloat(ratiovalue)>=1.0 || parseFloat(ratiovalue)<0.0){
		$.jBox.tip('提成点数输入不合法', 'error');
		return false;
	}
	if(!re.test(balance)  || parseFloat(balance)<0.0){
		$.jBox.tip('余额输入不合法', 'error');
		return false;
	}
	if(!ide.test(identi)){
		$.jBox.tip('身份证输入不合法', 'error');
		return false;
	}
	var account_type = $("#account_type").val()
	if (!(account_type == 0 || account_type == 1)){
	    $.jBox.tip('未选择账户类型', 'error');
		return false;
	}
	var id=$("#id").val();
	if(!($("#account").val()) || !($("#name").val()) || !($("#account_type").val()) ){
		$("#requiredInputsMSG").css({"display":"inline"});
		return false;
	}
	return true;
}

function select_accounttype(){
	accounttype = $("#account_type").val()
	if(accounttype == 0){
		$("#mac").removeAttr('disabled');
		$("#mac").removeAttr('style');
		$("#agent").removeAttr('disabled');
	}
	if(accounttype == 1){
		$("#mac").attr('disabled','disabled' );
		$("#mac").attr('style','background-color:#C0C0C0' );
		$("#agent").attr('disabled','disabled');
		
	}
}
</script>


<form id='addAccount_form' method="post">
<fieldset class='addAccount_form'>
	<legend style='padding: 5px 10px 0'>
		添加额度账户
	</legend>
		<table  align="center">
			<tr>
				<div id="requiredInputsMSG" style="display:none"><font color="#ff0000">请确保所有必填信息已经填入</font></div>
			</tr>
			<tr>
			<td class="required formLabel">额度帐号：</td>
			<td class="required formLabel">
				<input class="input" type="text" name="account"  id="account" value="" required="true" maxlength="20">
			</td>
			<td class="required formLabel">余额：</td>
			<td class="required formLabel">
				<input class="input" type="text" name="balance" id="balance" value="0.0" required="true" maxlength="20"  >
			</td>
		</tr>
		
		
		
		
		
		
		<tr>
			<td class="required formLabel">姓名：</td>
			<td class="required formLabel">
				<input class="input" type="text" name="name" id="name" value="" required="true">
			</td>
			<td class="required formLabel">身份证：</td>
			<td class="required formLabel">
				<input class="input" type="text" name="identify" id="identify" value="" required="true">
			</td>
		</tr>
		
		<tr>
			<td class="required formLabel">登录名：</td>
			<td class="required formLabel">
				<input class="input" type="text" name="loginname" id="loginname" value="" required="true" maxlength="20">
			</td>
			<td class="required formLabel">账户类型：</td>
			<td class="required formLabel">
				<select name="account_type" id="account_type" onchange="select_accounttype();">
				    <option>请选择账户类型</option>
					<option value="0">店主账户</option>
					<option value="1">代理账户</option>

				
				</select>
			</td>
		</tr>
		
		<tr>
			<td class="required formLabel">开户行：</td>
			<td class="required formLabel">
				<input class="input" type="text" name="bankname" id="bankname" value="" required="true"  >
			</td>
			<td class="required formLabel">银行卡号：</td>
			<td class="required formLabel">
				<input class="input" type="text" name="bank_num" id="bank_num" value="" required="true">
				<input type="hidden" value="{{account.id}}" name="accountid">
			</td>
		</tr>

		<tr>
			<td class="required formLabel">机器编码：</td>
			<td class="required formLabel">
			
				<input class="input"  type="text" name="mac" id="mac" value="{{account.mac}}" required="true" >
			</td>		
			<td class="required formLabel">代理商：</td>
			<td class="required formLabel">
				<select name="agent" id="agent">
				<option value="-1">选择代理商</option>
				{% for ac in account1 %}
				    
					<option value="{{ac.id}}">{{ac.loginname}}</option>
				{% endfor %}
				</select>
			</td>			
		</tr>
		<tr>
			<td class="required formLabel">提成点数：</td>
			<td class="required formLabel">
				<input class="input" type="text" name="ratio" id="ratio" value="0.0" required="true"  >
			</td>
			<td class="required formLabel">联系电话：</td>
			<td class="required formLabel">
				<input class="input" type="text" name="telephone" id="telephone" value="" required="true">
			</td>
		</tr>
		<tr>
			<td class="required formLabel">联系地址：</td>
			<td class="required formLabel" colspan="3">
				<input class="input1" type="text" name="address" id="address" value="" required="true"  maxlength="33">
			</td>
		</tr>
		
		
		    
		    <tr>
		    <td></td>
				<td class="required formLabel">
				   <input type="button" value="确定" onclick="submit_account();" style="border: 1px solid #3580A9;text-shadow: 0px -1px 0px #2C6AA3;font-weight: bold;font-size:12px;padding: 5px 10px;border-radius: 3px 3px 3px 3px;box-shadow: 0px 1px 5px #B2B2B2;">
                   </td><td></td><td class="required formLabel">
                   <input type="reset" value="重置"  style="border: 1px solid #3580A9;text-shadow: 0px -1px 0px #2C6AA3;font-weight: bold;font-size:12px;padding: 5px 10px;border-radius: 3px 3px 3px 3px;box-shadow: 0px 1px 5px #B2B2B2;">
		  		</td>
			</tr>
		</table>
</fieldset>
</form>



